package com.wb3.meta.api.core.controller;

import com.wb3.meta.api.core.service.ToysWorldService;
import com.wb3.meta.api.core.vo.ReqToysWorldVo;
import com.wb3.meta.common.annotation.NoPermission;
import com.wb3.meta.common.annotation.RequireAuth;
import com.wb3.meta.common.plugin.BaseResultController;
import com.wb3.meta.common.pojo.ResultT;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@Api(tags = "崽崽-世界接口")
@RequestMapping("base/toys/world/")
public class ToysWorldController extends BaseResultController<ReqToysWorldVo> {

    @Autowired
    private ToysWorldService toysWorldService;
    /**
     * 列表接口
     *
     * @param reqToysWorldVo
     */
    @Override
    @ApiOperation("列表接口")
    @GetMapping("list")
    public ResultT list(ReqToysWorldVo reqToysWorldVo) {

        return toysWorldService.getModelMapPage(reqToysWorldVo);
    }


    /**
     * 明细接口
     *
     * @param reqToysWorldVo
     */
    @Override
    @RequireAuth
    @ApiOperation("详情接口")
    @GetMapping("detail")
    public ResultT detail(ReqToysWorldVo reqToysWorldVo) {
        return toysWorldService.getResModelMapByConditions(reqToysWorldVo);
    }

    /**
     * 新增or更新接口
     *
     * @param reqToysWorldVo
     */
    @NoPermission
    @Override
    @ApiOperation("更新接口")
    @PostMapping("update")
    public ResultT saveOrUpdate(@RequestBody ReqToysWorldVo reqToysWorldVo) {
        return toysWorldService.saveOrUpdate(reqToysWorldVo);
    }

    /**
     * 删除接口
     *
     * @param reqToysWorldVo
     */
    @NoPermission
    @Override
    @ApiOperation("删除接口")
    @PostMapping("delete")
    public ResultT delete(@RequestBody ReqToysWorldVo reqToysWorldVo) {
        return toysWorldService.delete(reqToysWorldVo);
    }

    @RequireAuth
    @ApiOperation("事件接口")
    @GetMapping("event")
    public ResultT getWorldEvent(ReqToysWorldVo reqToysWorldVo) throws IOException {
        return toysWorldService.getWorldEvent(reqToysWorldVo);
    }

    @RequireAuth
    @ApiOperation("事件-选择接口")
    @PostMapping("event/choose")
    public ResultT eventChoose(@RequestBody ReqToysWorldVo reqToysWorldVo) throws IOException {
        return toysWorldService.eventChoose(reqToysWorldVo);
    }
    @RequireAuth
    @ApiOperation("事件-加速接口")
    @PostMapping("event/accelerate")
    public ResultT eventAccelerate(@RequestBody ReqToysWorldVo reqToysWorldVo) throws IOException {
        return toysWorldService.eventAccelerate(reqToysWorldVo);
    }

    @RequireAuth
    @ApiOperation("抽奖接口")
    @PostMapping("raffle")
    public ResultT raffle(@RequestBody ReqToysWorldVo reqToysWorldVo) throws IOException {
        return toysWorldService.raffle(reqToysWorldVo);
    }
}
